package com.gamenew.bluetoothdemo.ui.activity;

import android.content.Context;
import android.content.Intent;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;

import com.gamenew.bluetoothdemo.R;
import com.gamenew.bluetoothdemo.bean.EventBusWrite;
import com.gamenew.bluetoothdemo.ui.fragment.MusicModeFragment;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

public class MusicActivity extends AppCompatActivity {


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_music);

        EventBus.getDefault().register(this);

        FragmentManager manager = getSupportFragmentManager();
        FragmentTransaction bt = manager.beginTransaction();
        bt.add(R.id.music_content, new MusicModeFragment()).commit();
    }


    @Override
    protected void onDestroy() {
        super.onDestroy();
        EventBus.getDefault().unregister(this);
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void writeCommon(EventBusWrite event){
        Log.i("event--", "writeCommon: "+event.functionTag);
    }

    public static void actionActivity(Context context) {
        Intent intent = new Intent(context, MusicActivity.class);
        context.startActivity(intent);
    }
}
